import axios from './axios'
import qs from 'qs'
import { apiUrl, appUrl } from '@/config/config'

// ——————————————————————————————  校园缴费模块Api  ——————————————————————————————————————————

// 获取缴费记录列表
export const getListApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/home/recordStudentSchoolFees',
      method: 'get',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 微信支付 （发起）
export const initiatePayment = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/home/recordStudentSchoolFees/pay',
      method: 'post',
      data: params
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 微信支付 （刷新订单状态）
export const paymentRefresh = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/home/recordStudentSchoolFees/refreshPayState',
      method: 'post',
      data: params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 标记记录已读状态
export const setRead = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/school/api/home/recordStudentSchoolFees/readRecordStudentSchoolFees',
      method: 'post',
      data: params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}



// ——————————————————————————————  通知详情模块Api  ——————————————————————————————————————————

// 教师获取出入校异常通知列表
export const inAndOutList = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/consumer/api/consumer/schoolInOutAbnormal/inOutAbnormal',
      method: 'get',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 更改学生出入校状态
export const changeStatusApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/consumer/api/consumer/schoolInOutAbnormal/inOutAbnormal',
      method: 'put',
      data: params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 获取单个学生异常详情
export const singleExceptionApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/consumer/api/consumer/schoolInOutAbnormal/studentInOutAbnormal',
      method: 'get',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 教师确认异常并推送家长  (单个推送)
export const pushParentsApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/consumer/api/consumer/schoolInOutAbnormal/abnormalToParent/'+ params,
      method: 'get'
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 教师确认异常并推送家长  (集体推送)
export const groupPushApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/consumer/api/consumer/schoolInOutAbnormal/sendParentWeChar',
      method: 'get',
      params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 平台误报请求
export const positiveApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/consumer/api/consumer/schoolInOutAbnormal/platformFalseAlarm/' + params,
      method: 'get'
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
